import React, { useState } from 'react';
import './index.scss'
import { DownloadOutlined } from '@ant-design/icons';
import { Button} from 'antd';

export default function OrderBody() {
  const daochu=(e)=>{
    var toExcel = function(event) {
        // 获得表格数据的html标签和文本d;
        var html = "<html><head><meta charset='UTF-8'></head><body>"+document.getElementsByClassName('ant-table-content')[0].outerHTML+"</body></html>";
        // 创建一个Blob对象，第一个参数是文件的数据，第二个参数是文件类型属性对象
        var blob = new Blob([html],{type:"application/vnd.ms-excel"});
        var a = e.target;
        // 利用URL的createObjectURL方法为元素a生成blobURL
        a.href = URL.createObjectURL(blob);
        // 设置文件名
        a.download = "订单信息";
    }
    toExcel()
  }
  
  // 按钮大小
  const [middle ] = useState('middle ');
  return (
    <div id='bodyBigBox'>
      <div>
        <Button type="primary" icon={<DownloadOutlined />} size={middle } style={{margin:'11px 30px'}}><a href='https://www.baidu.com/index.php?tn=monline_3_dg' onClick={daochu} style={{color:'white'}}>导出订单</a></Button>
      </div>
    </div>
  )
}
